package com.xbongbong.paas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;

/**
 * @author: wufeng
 * @date: 2018/10/24 16:59
 * @desrcption: 下拉框，下拉复选的选项(0:自定义 1：关联其他表单 2：数据联动)
 */
public enum ComboTypeEnum {

    /**
     * 选项的三种类型
     */
    CUSTOM(0, "custom", "enum.comboType.memo.custom"),

    LINKFORM(1, "linkForm", "enum.comboType.memo.linkform"),

    DATARELY(2, "dataRely", "enum.comboType.memo.datarely"),

    BUSINESS(3, "business", "enum.defaultType.memo.business_field"),
    ;


    private Integer type;

    private String alias;

    private String memo;

    ComboTypeEnum(Integer type, String alias, String memo){
        this.type =type;
        this.alias = alias;
        this.memo = memo;
    }

    public Integer getType() {
        return type;
    }

    public String getAlias() {
        return alias;
    }

    public String getMemo() {
        return I18nMessageUtil.getMessage(memo);
    }

    public static ComboTypeEnum getComboTypeEnum(Integer type){
        for (ComboTypeEnum combo: values()){
            if(combo.getType().equals(type)){
                return combo;
            }
        }
        return null;
    }
    /**
     * 获取选项描述
     * @param type
     * @return java.lang.String
     * @author zcp
     * @date 2019/6/30 21:09
     * @since v1.0
     * @version v1.0
     */
    public static String getComboTypeMemo(Integer type){
        for (ComboTypeEnum combo: values()){
            if(combo.getType().equals(type)){
                return combo.getMemo();
            }
        }
        return null;
    }
}
